package TCP_test2;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;
import java.util.concurrent.*;

public class Server {
    public static void main(String[] args) throws IOException {
        //
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
                5,
                10,
                30,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(2),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        //创建服务器对象
        ServerSocket ss = new ServerSocket(8888);
//        //创建线程对象
//        MyThread myThread = new MyThread(serverSocket);
//        //开启线程  一个用户对应一个线程
//        new Thread(myThread).start();
        while (true) {
            Socket socket = ss.accept();
            pool.submit(new MyThread(ss));
        }
    }
}
